<template>
    <div class="page-wrapper">
        <div class="page-wrapper__body">
            <div class="page-container is-form" v-loading="isLoading">
                <el-form ref="roleForm" :model="model" label-width="140px" label-position="left">
                    <div class="block-title"><i>¶</i>
                        <el-button type="default" icon="el-icon-back" round size="mini" class="more" @click="onBack">
                            返回
                        </el-button>
                        岗位招聘信息
                    </div>
                    <div style="height:20px;"></div>
                    <el-form-item label="项目: ">
                        <p class="form-text" v-html="model.project"></p>
                    </el-form-item>
                    <el-form-item label="招聘岗位: ">
                        <p class="form-text" v-html="model.jobTitle"></p>
                    </el-form-item>
                    <el-form-item label="职能名称: ">
                        <p class="form-text" v-html="model.jobType"></p>
                    </el-form-item>
                    <el-form-item label="岗位职责: ">
                        <p class="form-text" v-html="model.jobDesc"></p>
                    </el-form-item>
                    <el-form-item label="任职要求: ">
                        <p class="form-text" v-html="model.requirement"></p>
                    </el-form-item>
                    <el-form-item label="工作地点: ">
                        <p class="form-text" v-html="model.workPlace"></p>
                    </el-form-item>
                    <el-form-item label="学历要求: ">
                        <p class="form-text" v-html="model.eduDegree"></p>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    import {getDetail} from "../../api/job/mengniu";

    export default {
        name: "detail",
        data() {
            return {
                model: {},
                params: {
                    id: 0
                },
                isLoading: false
            }
        },
        methods: {
            onBack() {
                this.$router.push('/mengniu/job/list')
            },
            async loadData() {
                if (this.params.id <= 0) {
                    this.$alert('参数错误', '提示', {
                        confirmButtonText: '确定', okFn: () => {
                            this.onBack()
                        }
                    });
                    return false;
                }
                this.isLoading = true;
                let resp = await getDetail(this.params.id);
                if (!this.qUtil.validResp(resp)) {
                    this.isLoading = false;
                    this.$alert('请求数据失败!', '提示', {
                        confirmButtonText: '确定', okFn: () => {
                            this.onBack()
                        }
                    });
                    return false;
                }
                this.model = resp.data.model || {};
                this.model.jobDesc = this.model.jobDesc.replace(/\n/g, '\<br\/\>');
                this.model.requirement = this.model.requirement.replace(/\n/g, '\<br\/\>');
                this.isLoading = false;
            },
        },
        mounted() {
            this.params.id = parseInt(this.$route.params.id) || 0;
            this.loadData();
        }
    }
</script>

<style scoped>
    .form-text {
        margin-top: -6px;
        text-align: left;
        line-height: 30px;
        font-size: 14px;
        color: #666;
    }
</style>